![]() 03/23/2016 at 21:59 • Filed to: None | ![]() | ![]() |
I don’t know if I did this right.
http://media.education2020.com.education2020.us/manuals/CSC210…
Yes i’m asking for homework help on oppo.
![]() 03/23/2016 at 22:04 |
|
Looks good. Shouldn’t be obvious if it’s right by running it?
I’d run it if it weren’t a screenshot ;)
![]() 03/23/2016 at 22:07 |
|
You didn’t spell “dorque” correctly.
![]() 03/23/2016 at 22:07 |
|
I thought about it until i looked and saw this and I don’t seem to get what its asking. “b. Reassign the new list value to the variable name string_to_list. TIP: You can do this by adding the variable name and an equals sign before the code that creates the new list value.”
![]() 03/23/2016 at 22:08 |
|
lol
![]() 03/23/2016 at 22:12 |
|
Just run it, it won’t hurt ;)
For the record, it’s mostly, but not quite right. The results from running it might give you a clue as to what needs to be changed.
![]() 03/23/2016 at 22:12 |
|
from collections import deque
list_stack = []
list_queue = deque([])
string_to_list = “who what when where why how”
string_to_list.split()
for i in string_to_list:
list_stack.append(i)
list_queue.appendleft(i)
print(“The value created as a stack:”, list_stack)
print(“The value created as a queue:”, list_queue)
![]() 03/23/2016 at 22:16 |
|
I mean it seems right: The value created as a stack: [’w’, ‘h’, ‘o’, ‘ ‘, ‘w’, ‘h’, ‘a’, ‘t’, ‘ ‘, ‘w’, ‘h’, ‘e’, ‘n’, ‘ ‘, ‘w’, ‘h’, ‘e’, ‘r’, ‘e’, ‘ ‘, ‘w’, ‘h’, ‘y’, ‘ ‘, ‘h’, ‘o’, ‘w’]
The value created as a queue: deque([’w’, ‘o’, ‘h’, ‘ ‘, ‘y’, ‘h’, ‘w’, ‘ ‘, ‘e’, ‘r’, ‘e’, ‘h’, ‘w’, ‘ ‘, ‘n’, ‘e’, ‘h’, ‘w’, ‘ ‘, ‘t’, ‘a’, ‘h’, ‘w’, ‘ ‘, ‘o’, ‘h’, ‘w’])
Save and run the program. Make sure it prints the list_stack and list_queue values when it runs. TIP: The stack and queue values will include the elements in reverse order from one another.
![]() 03/23/2016 at 22:16 |
|
I think that’s just saying use:
string_to_list = string_to_list.split()
In fact that’s a good point. I don’t think your code will work. In Python strings are immutable which means you can’t change them. For:
string_to_list.split()
To work it needs to modify the value of string_to_list. I think it will only return the value, which means you’re not storing it and it’s being lost.
But that should be very obvious if you’ve run it ;)
![]() 03/23/2016 at 22:17 |
|
I don’t even wish I knew how to help with whatever the hell this is
![]() 03/23/2016 at 22:18 |
|
In this example I:
- Create a variable named “variable”
- Assign a string to it
- Split the string, which returns the result in square brackets - an actual list
- Show the contents of the variable, which still contains the unsplit string
So to store the list value, I’d need to re-assign it to my variable using:
variable = variable.split()
![]() 03/23/2016 at 22:20 |
|
Obviously, I hate coding.
![]() 03/23/2016 at 22:21 |
|
So it’s meant to be like this?
from collections import deque
list_stack = []
list_queue = deque([])
string_to_list = “who what when where why how”
string_to_list = string_to_list.split()
string_to_list.split()
for i in string_to_list:
list_stack.append(i)
list_queue.appendleft(i)
print(“The value created as a stack:”, list_stack)
print(“The value created as a queue:”, list_queue)
![]() 03/23/2016 at 22:25 |
|
That’s the correct approach. Except you’ve still got the line:
string_to_list.split()
In there which isn’t required will throw an error.
Again, you should be able to run it to prove it works. I have :) If you don’t know how to execute your code, I can tell you.
The world of software is based on testing, something only works when you’ve tested it thoroughly to prove that it does. No one will trust your code until it’s run.
And you need to understand why it worked! Immutability is a design choice in Python and will affect the way you code!
![]() 03/23/2016 at 22:28 |
|
It’s asking you to get the words in reverse order to each other. This has done the letters of the strings, not the words, because your split isn’t being applied.
![]() 03/23/2016 at 22:31 |
|
Wow! thank you so much for helping me I got the result I wanted :D
![]() 03/23/2016 at 22:37 |
|
What language is this?
![]() 03/23/2016 at 22:37 |
|
Python
![]() 03/23/2016 at 23:01 |
|
English
![]() 03/23/2016 at 23:05 |
|
Programming language..... Smartass.
![]() 03/23/2016 at 23:09 |
|
Yeah, it’s the Programming language. So why’d you ask?
![]() 03/23/2016 at 23:16 |
|
Because I wasn’t sure what it was.
![]() 03/23/2016 at 23:20 |
|
But you know it’s the Programming language. You must’ve learned some Programming to know it’s the Programming language. Have you ever been to Programming? I think you’d enjoy it quite well. The Programmingers would prefer you speak Programming though, and not English.
![]() 03/23/2016 at 23:22 |
|
I’ve done a little Java
![]() 03/23/2016 at 23:28 |
|
I GIVE UP I WAS TRYING TO BE SOMEWHAT FUNNY AHHH
![]() 03/23/2016 at 23:31 |
|
Daily has gotten the recommended 8 hours of sleep.
Granted those 8 hours have been spread out since last weekend. I haven’t slept more than 3 hours a night this week. I am too tired to understand humor. Does not compute.
![]() 03/23/2016 at 23:34 |
|
I’ve gotten 8 hours the past 2 nights so kiiinda know that feel. Today I fell asleep probably like 6 times in my 2 classes.
![]() 03/23/2016 at 23:37 |
|
I’ll just sleep during spring break. Oh wait. No I won’t.
![]() 03/23/2016 at 23:51 |
|
Nice :D
![]() 03/23/2016 at 23:55 |
|
don’t mix up your : and ;. That bit me in the ass twice.